Skip to content

test(conversions): test invariant of feetToMeter with 100 bounded cases (R50-T044) - #92

Open
aniruddha-bongale wants to merge 1 commit into
S-AI-Projects:masterfrom
aniruddha-bongale:student/e26b07f0827/R50-T044
Open

aniruddha-bongale wants to merge 1 commit into
S-AI-Projects:masterfrom
aniruddha-bongale:student/e26b07f0827/R50-T044

Conversation

@aniruddha-bongale

Copy link
Copy Markdown

Description

This PR addresses task R50-T044 for feetToMeter. It introduces invariant and property-based regression tests across 100 bounded valid inputs generated with a deterministic seed, verifies the constant scale ratio, round-trip invertibility, linearity, and monotonicity invariants, documents the mathematical contract next to feetToMeter in Conversions/MeterToFeetConversion.js, and adds an automated check runner work/R50-T044/check.py that confirms sensitivity against deliberately broken mutants.

Related Issue

Fixes: #44

Type of Change

  • Tests
  • Documentation
  • Refactoring / Maintenance

Changes Made

  • Documented invariant and property contracts beside feetToMeter in Conversions/MeterToFeetConversion.js citing precondition checks at Line 18.
  • Added comprehensive property-based tests in Conversions/test/MeterToFeetConversion.test.js:
    • Stated fixtures: smallest valid length (0 feet -> 0 meters) and ordinary input (10 feet -> 3.048 meters).
    • 100 bounded valid cases generated with a deterministic fixed-seed LCG in range [0.01, 1000.0].
    • Invariant checks: ratio invariance (Math.abs(feetToMeter(x)/x - 0.3048) < 1e-12), round-trip invertibility with meterToFeet (< 1e-9), linearity/additivity (feetToMeter(a+b) === feetToMeter(a) + feetToMeter(b)), and strict monotonicity.
    • Smallest failing case detection under an altered scaling mutant.
  • Implemented automated check runner work/R50-T044/check.py with mutant detection verification and saved verifiable results in work/R50-T044/results.json.

Screenshots / Recordings

N/A (Unit / property test suite)

Testing

  • Ran Prettier style checks: npx prettier --check Conversions/MeterToFeetConversion.js Conversions/test/MeterToFeetConversion.test.js work/R50-T044/results.json
  • Ran native Vitest suite: npm test -- Conversions/test/MeterToFeetConversion.test.js (9 tests passed)
  • Ran full repository test suite via pre-commit hook (346 test files, 11,977 tests passed)
  • Ran automated check runner: python3 work/R50-T044/check.py (all checks and tool version captures passed)

Checklist

  • I have tested my changes locally.
  • I have added or updated tests, if needed.
  • I have updated documentation, if needed.
  • I have followed the project's coding guidelines.
  • I have run the relevant tests and checks.
  • I have addressed previous review feedback, if applicable.

Additional Notes

  • Precondition source line 18 is explicitly cited in code comments, test descriptions, and automated check results.
  • The generator does not rely on undefined behavior, and the checks verify defect sensitivity against broken mutants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aniruddha Bongale — R50-T044: Test an invariant of feetToMeter (MeterToFeetConversion.js) [Conversions/MeterToFeetConversion.js]

1 participant